﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IllustratedCsharp7_ch8
{
    class chapt8_6_OverrideOtherMemberType
    {
        static void _Main()
        {
            MyDerivedClass derived = new MyDerivedClass();
            MybaseClss mybc =(MybaseClss)derived;
            Console.WriteLine(derived.MyProperty);
            Console.WriteLine(mybc.MyProperty);
        }
    }

    class MybaseClss
    {
        private int _myInt = 5;
        virtual public int MyProperty
        {
            get { return _myInt; }
        }
    }

    class MyDerivedClass : MybaseClss
    {
        private int _myInt = 10;
        new public  int MyProperty  //new 或override产生不同的输出
        {
            get { return _myInt; }
        }
    }
}
